</br>
<?php
echo validation_errors('<div class="error">', '</div>');
if ($this->session->flashdata('error')) {
    echo "<div class='message'>";
    echo $this->session->flashdata('error');
}
?>
<div class="panel panel-default">
    <div class="panel-heading"><?= $_SESSION['nombres_medico'] . ' ' . $_SESSION['apellidos_medico'] ?></div>
    <div class="panel-body">
<?= $calendario ?>
        <input type="hidden" value="<?= $this->uri->segment(3) ?>" class="year" />
        <input type="hidden" value="<?= $this->uri->segment(4) ?>" class="month" />
    </div>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">Horarios</h4>
            </div>
            <div class="modal-body">
                <?php
                echo '</br>';
                echo"<table>";
                echo"<tr>";
                echo"<td>";
                echo '</div>';
                echo"</td>";
                echo"</tr>";
                echo"</table>";

                if ($horarios == null) {
                    echo 'No Hay Medicos';
                } else {
                    echo '<table cellpadding="0" cellspacing="0" border="1" class="table table-striped table-bordered table-condensed table-responsive" id="agenda" width="100%">';
                    echo "<thead>\n<tr>\n";
                    echo "<th>Hora de Inicio</th><th>Hora Fin</th><th>Agendar Cita</th><th>detalles Cita</th>\n";

                    foreach ($horarios as $fila) {
                        echo form_open("cita_medica_controller/guardar/" . $fila['id'] . "");
                        echo '<tbody>';
//                        if ($horarios_medico != null) {
//                            foreach ($horarios_medico as $row) {
//                                if ($row['id'] == $fila['id']) {
//                                    $btn_editar = array(
//                                        'class' => 'btn btn-sm btn-primary btn-block',
//                                        'value' => 'Reservado'
//                                    );
//                                }
//                            }
//                        } else {
                        $btn_editar = array(
                            'class' => 'btn btn-sm btn-primary btn-block',
                            'value' => 'Reservar'
                        );
//                        }
                        $btn_detalle = array(
                            'class' => 'btn btn-sm btn-primary btn-block',
                            'value' => 'Detalle'
                        );
                        echo '<input type="hidden" name="fecha" value=""/>';
                        echo "<tr valign='top'>\n";
                        echo "<td align='left'>" . $fila['hora_inicio'] . "</td>";
                        echo "<td align='left'>" . $fila['hora_fin'] . "</td>";
                        echo'<td align="left">';
                        echo form_submit($btn_editar);
                        echo form_close();
                        echo '</td>';
                        echo'<td align="left">';
                        echo form_open("cita_medica_controller/detalle/");
                        echo '<input type="hidden" name="fechax" value=""/>';
                        echo form_submit($btn_detalle);
                        echo form_close();
                        echo '</td>';
                        echo "</tr>\n";
                    }
                    echo "</tbody>  ";

                    echo '</table>';
                }
                ?>
            </div>
        </div>
    </div>
</div>

